<template>
  <div class="header-container">
    <div class="content">
      <div class="pic">
        <img :src="img_url" alt="" />
      </div>
      <div class="desc-info">
        <div class="title">{{ title }}</div>
        <div class="price-box">
          <div class="normal-price">
            <span>￥</span>
            <span class="price">{{ price }}</span>
            <span>起</span>
          </div>
          <div class="plus-price">
            <span class="plus-icon" v-if="plus_desc">
              <van-icon size="16px" color="#C7993A" name="arrow-down" />
            </span>
            <span class="plus-desc" @click="$router.push('/cardpage')" v-if="plus_desc">会员价￥{{ plus_desc }}</span>
          </div>
        </div>
        <div class="view-count">{{ getCount(view_count) }}人看过</div>
      </div>
    </div>
    <!-- 开通会员 -->
    <div class="plus-box" @click="$router.push('/cardpage')">
      <div class="detail">
        <div class="plus-info">
          <div class="top">
            <van-icon size="24px" color="#E8D09B" name="arrow-down" />
            <span class="save">超级会员</span>
          </div>
          <div class="save-count">本单省{{ go_card_discount }}</div>
        </div>
        <div class="bottom">会员享88折,还有140元玩乐卷</div>
      </div>
      <div class="btn">
        <span>立即开通</span>
        <span>
          <van-icon name="arrow" color="#fff" />
        </span>
      </div>
    </div>
    <!-- 地址 -->
    <div class="address-info">
      <div class="address-box">
        <div class="time-box">
          <span class="icon"></span>
          <span class="time">{{ time }}</span>
        </div>
        <div class="address" @click="$router.push('/businesses/' + id)">
          <span class="icon"></span>
          <span class="desc">
            <span class="detail-address">{{ name }}</span>
            <van-icon name="arrow" color="#333" size="16" />
          </span>
          <span class="activity"> {{ feed_count }}个活动 </span>
        </div>
      </div>
      <div class="navigation">
        <span class="icon-bg">
          <i class="icon"></i>
        </span>
      </div>
    </div>
    <!-- tags -->
    <div class="tag-box" @click="$emit('edit-show')">
      <span class="title">服务</span>
      <span class="tags">
        <span>
          <i class="icon icon-1"></i>
          正品保障
        </span>
        <span>
          <i class="icon icon-2"></i>
          假一赔三
        </span>
        <span>
          <i class="icon icon-3"></i>
          极速售后
        </span>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    img_url: String,
    title: String,
    price: [Number, String],
    plus_desc: String,
    view_count: Number,
    go_card_discount: String,
    feed_count: Number,
    name: String,
    time: String,
    id: [Number, String]
  },
  methods: {
    getCount(count) {
      if (count < 10000) {
        return count
      } else {
        const re = /^\d+\.?\d?/
        let res = count / 10000 + ''
        return parseFloat(res.match(re)) + '万'
      }
    }
  }
}
</script>

<style lang="less" scoped>
.header-container {
  padding: 10px;
  padding-top: 20px;
  border-top-right-radius: 15px;
  border-top-left-radius: 15px;
  background-color: #fff;
  transform: translateY(-30px);

  .content {
    display: flex;
    justify-content: center;

    .pic {
      height: 100px;
      width: 80px;
      img {
        height: 100%;
        width: 100%;
      }
    }
    .desc-info {
      padding-left: 10px;
      flex: 1;

      .title {
        font-size: 18px;
        font-weight: 700;
        color: #4a4a4a;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis; /*显示为......*/
        -webkit-line-clamp: 2; /*显示为两行，在第二行中显示为.......*/
        display: -webkit-box;
        -webkit-box-orient: vertical;
      }
      .price-box {
        padding: 8px 0;
        display: flex;
        align-items: center;
        color: #4a4a4a;

        .normal-price {
          display: flex;
          font-size: 14px;
          margin-right: 10px;
          line-height: 20px;
          font-weight: 600;
          align-items: flex-end;

          span {
            height: 24px;
            line-height: 24px;
          }
          .price {
            display: flex;
            padding: 0 2px;
            font-weight: 700;
            font-size: 24px;
            justify-content: flex-end;
          }
        }
        .plus-price {
          border-radius: 999px;
          display: flex;
          align-self: flex-end;
          align-items: center;
          font-size: 12px;
          line-height: 20px;
          background-color: #f2dfae;
          .plus-icon {
            height: 18px;
            width: 18px;
            text-align: center;
            display: inline-block;
            margin-right: 5px;
            background-color: #1d1c1b;
            border-radius: 999px;

            .van-icon {
              font-weight: 700;
              transform: scale(0.6, 1.2);
            }
          }
          .plus-desc {
            font-weight: 700;
            padding-right: 10px;
          }
        }
      }
      .view-count {
        font-size: 12px;
        color: #c5c5c5;
      }
    }
  }

  .plus-box,
  .address-info {
    display: flex;
    padding: 8px 15px;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
    border-radius: 999px;

    &.plus-box {
      color: #fff;
      margin-top: 30px;
      background-image: linear-gradient(to right, #de3d3b, #ff7f53);

      .detail {
        display: flex;
        flex-direction: column;
        .plus-info {
          display: flex;
          .top {
            border-radius: 999px;
            background-color: #1d1c1b;
            padding-right: 10px;
            height: 20px;
            overflow: hidden;
            display: flex;
            align-items: center;

            .van-icon {
              font-weight: 700;
              transform: scaleX(0.5);
            }
            .save {
              color: #e8d09b;
              font-size: 14px;
              line-height: 20px;
            }
          }
          .save-count {
            font-size: 14px;
            font-weight: 500;
            line-height: 20px;
            margin-left: 10px;
          }
        }

        .bottom {
          margin-top: 3px;
          font-size: 12px;
          line-height: 20px;
        }
      }
      .btn {
        border-radius: 999px;
        font-size: 14px;
        line-height: 24px;
        padding: 2px 10px 2px 15px;
        background-color: #d94648;
      }
    }

    &.address-info {
      color: #333333;
      margin-top: 20px;
      background-color: #f0f0f0;

      .address-box {
        .time-box,
        .address {
          font-weight: 700;
          display: flex;
          align-items: center;

          .activity {
            font-size: 12px;
            margin-left: 5px;
            border-radius: 999px;
            border: 1px solid #7694ca;
            color: #7694ca;
            padding: 0 10px;
            line-height: 20px;
          }

          .icon {
            height: 16px;
            width: 16px;
            margin-right: 10px;
            background-repeat: no-repeat;
            background-size: cover;
          }
          &.time-box {
            .icon {
              background-image: url('@/assets/head/aO.png');
            }
          }
          .time,
          .desc {
            font-size: 14px;
            line-height: 20px;

            .van-icon {
              font-weight: 700;
              transform: translateY(1px);
            }
          }
          &.address {
            .icon {
              background-image: url('@/assets/head/3g.png');
            }
          }
        }
      }
      .navigation {
        position: relative;
        display: flex;

        &::before {
          position: absolute;
          top: 50%;
          left: -15px;
          height: 25px;
          transform: translateY(-50%);
          content: '';
          display: block;
          border-left: 2px solid rgb(212, 219, 235);
          z-index: 20;
        }
        .icon-bg {
          height: 30px;
          width: 30px;
          border-radius: 999px;
          background-image: url('@/assets//head/Pu1.png');
          background-repeat: no-repeat;
          background-size: cover;
        }
      }
    }
  }
  .tag-box {
    display: flex;
    padding-top: 20px;
    padding-bottom: 20px;

    .title {
      margin-right: 10px;
      font-size: 16px;
      color: #333;
      font-weight: 900;
      line-height: 20px;
    }

    .tags {
      display: flex;
      align-items: center;
      span {
        line-height: 18px;
        font-size: 14px;
        margin: 0 10px;
        display: flex;
        color: #e9c387;

        .icon {
          height: 16px;
          width: 16px;
          margin-right: 3px;
          background-repeat: no-repeat;
          background-size: cover;
        }
        .icon-1 {
          background-image: url('@/assets//head/k6.png');
        }
        .icon-2 {
          background-image: url('@/assets//head/Ut.png');
        }
        .icon-3 {
          background-image: url('@/assets//head/b9.png');
        }
      }
    }
  }
}
</style>
